# ----------------------------------------------------------------------------
#  Root CMake file for code particse
# ----------------------------------------------------------------------------

# Disable in-source builds to prevent source tree corruption.
if(" ${CMAKE_SOURCE_DIR}" STREQUAL " ${CMAKE_BINARY_DIR}")
  message(FATAL_ERROR "Please create a separate directory for build files.")
endif()

# specify version and policy
cmake_minimum_required(VERSION 2.8.7)
if(POLICY CMP0046)
  cmake_policy(SET CMP0046 NEW)
endif()
if(POLICY CMP0054)
  cmake_policy(SET CMP0054 NEW)
endif()

# Project Name 
project(code_partise C CXX)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_FLAGS  "-g -O0 -std=c++11")
# set(CMAKE_CXX_FLAGS  "-g -O0 -std=c++11 -fno-elide-constructors")

# file(GLOB_RECURSE srcs ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
file(GLOB srcs ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
foreach(source ${srcs})
    # message(${src})
    # get file name
    get_filename_component(name ${source} NAME_WE)
    add_executable(${name} ${source})
endforeach()
# add_executable(test_inout test.cpp)